package org.bite.lesson06;

public class Demo601 {
    public static void main(String[] args) {
        System.out.println("饿汉模式：");
        SingletonHungry instance1 = SingletonHungry.getInstance();
        SingletonHungry instance2 = SingletonHungry.getInstance();
        SingletonHungry instance3 = SingletonHungry.getInstance();
        System.out.println(instance1);
        System.out.println(instance3);
        System.out.println(instance2);
        System.out.println("可以看出都是引用的同一个对象");
        System.out.println("懒汉模式：");
        SingletonLazy instance4 = SingletonLazy.getInstance();
        SingletonLazy instance5 = SingletonLazy.getInstance();
        SingletonLazy instance6 = SingletonLazy.getInstance();
        System.out.println(instance6);
        System.out.println(instance4);
        System.out.println(instance5);
    }
}
